package com.chris.core.socket.netty.run;

import com.chris.core.socket.bio.util.BioSokcetClientUtil;
import com.chris.core.socket.netty.dto.SocketTypeEnum;
import com.chris.core.socket.netty.handler.StringClientHandler;
import com.chris.core.socket.netty.service.NettyClientService;
import com.chris.core.socket.netty.util.NettyClientUtil;
import com.chris.core.socket.netty.util.NettyRunTimeUtil;
import io.netty.channel.ChannelPipeline;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

public class allClient {
    public static void main(String[] args) throws InterruptedException, IOException {

        Logger log = LoggerFactory.getLogger("main");
        NettyRunTimeUtil.runTimeBreakMark="\r\n";
        /*
for (int j=0;j<=1;j++)
        {
            for (int i = 0; i < 1000; i++) {

                NettyClientUtil nettySocket = new NettyClientUtil(10102+j, 180, NettyRunTimeUtil.runTimeBreakMark,false, SocketTypeEnum.StringSocket) {
                    @Override
                    public void AddChannelHandler(ChannelPipeline pipeline) {
                        //自定义事件
                        pipeline.addLast(new StringClientHandler());
                    }
                };
                nettySocket.Open();

                Thread.sleep(5);
                System.out.println(i);
            }
        }
*/

        for (int j=0;j<=0;j++) {
            for (int i = 0; i < 30000; i++) {
                BioSokcetClientUtil aa = new BioSokcetClientUtil("127.0.0.1", (10102+j), 600000, false, NettyRunTimeUtil.runTimeBreakMark) {
                    @Override
                    public void OnRevice(String msg) {
                        if (msg.equals("write-ping"))
                            super.SendMsg("ping");
                        log.debug("客户端->读取->服务端:-->内容:" + msg);
                    }
                };
                aa.Open();
                Thread.sleep(1);
                System.out.println(j+"-"+i);
            }

        }


        while (true) {

        }
    }
}
